import { get, post } from '@/utils/http'

enum API {
  // 获取部门消息id列表
  GETDEPARTMENTMSG_API = '/departmentMsg/getDepartmentMsg',
  // 获取部门消息
  GETDEPARTMENTMSGLIST_API = '/departmentMsg/getDepartmentMsgList',
  // 返回用户的阅读列表及状态
  GETREADLISTANDSTATUS_API = '/departmentMsg/getReadListAndStatus',
  // 用户点击消息后对 read_list 删减
  UPDATEREADLIST_API = '/departmentMsg/updateReadList',
  // 把新发布文章的id插入到当前所属部门的rad_list当中
  CHANGUSERREADLIST_API = '/departmentMsg/changUserReadList',
  // 删除的文章id从readlist移除
  DELETEUSERREADLISTID_API = '/departmentMsg/DeleteUserReadListId'
}
// 获取部门消息id列表
export const getDepartmentMsgAPI = (id: number, department: string) => {
  return get<string>(API.GETDEPARTMENTMSG_API, { params: { id, department } })
}

// 获取部门消息
export const getDepartmentMsgListAPI = (department: string) => {
  return get<Message[]>(API.GETDEPARTMENTMSGLIST_API, { params: { department } })
}

// 返回用户的阅读列表及状态
export const getReadListAndStatusAPI = (id: number) => {
  return get<ReadListAndStatus[]>(API.GETREADLISTANDSTATUS_API, { params: { id } })
}

// 用户点击消息后对 read_list 删减
export const updateReadListAPI = (id: number, readId: number) => {
  return post(API.UPDATEREADLIST_API, { id, readId })
}

// 把新发布文章的id插入到当前所属部门的rad_list当中
export const changUserReadListAPI = (messageId: number, department: string) => {
  return post(API.CHANGUSERREADLIST_API, { messageId, department })
}

// 删除的文章id从readlist移除
export const DeleteUserReadListIdAPI = (deleteId: number, department: string) => {
  return post(API.DELETEUSERREADLISTID_API, { deleteId, department })
}
